package com.zhuchaooasystem.utils;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.provider.MediaStore;

import com.zhuchaooasystem.common.Key;

import java.io.File;

/**
 * @author yinsi
 *         <p/>
 *         系统相机工具类
 */
public class CameraUtils {
    // ----
    public static String imagePath = ""; //图片路径
    private File imageFile; //图片文件

    public CameraUtils() {

    }

    /**
     * 开始拍照
     *
     * @param activity
     */
    public void takePhoto(Activity activity) {
        try {
            imageFile = FileUtils.createImageFile(Key.PATH_LOCAL_IMAGE_CAMERA, CalendarUtils.getNow("yyyyMMddHHmmss"), ".png");
            imagePath = imageFile.getAbsolutePath();
            // ----
            Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
            intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(imageFile));
            activity.startActivityForResult(intent, 1);
        } catch (Exception e) {
        }
    }

}
